Array and Pointer
Q21.
The output of the following program is main() { static int x[] = {1,2,3,4,5,6,7,8} int i; for (i=2; i<6; ++i) x[x[i]]=x[i]; for (i=0; i<8; ++i) printf("%d", x[i]); }Q22.
Consider the following declaration: int a, *b=&a, **c=&bThe following program fragment a=4; **c=5;Q23.
Consider the following C program. #include < stdio.h > int main( ) { static int a[ ] = {10, 20, 30, 40, 50}; static int *p[ ] = {a, a+3, a+4, a+1, a+2}; int **ptr = p; ptr++; printf("%d%d", ptr-p,**ptr); }The output of the program is ______________.Q24.
Consider the following C program segment. #include < stdio.h > int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); } What will be printed by the program?Q25.
What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory. int main () { unsigned int x[4][3] ={{1,2,3},{4,5,6},{7,8,9},{10,11,12}}; printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3); }Q26.
What does the following fragment of C-program print? char c []="GATE2011"; char *p =c; printf ("%s", p + p[3]- p[ 1 ]);Q27.
Consider the following program in C language: # include < stdio.h > main() { int i; int * pi = &i scanf( "%d", pi) ; printf ("%d \ n", i+5) ; } Which one of the following statements is TRUE?Q28.
Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j, k; i = 0; j = n-1; do { k = (i+j)/2; if (x <= listA[k]) j = k-1; if (listA[k] <= x) i = k+1; }while (i <= j); if (listA[k] == x) return(k); else return -1; } Which one of the following statements about the function ProcessArray is CORRECT?Q30.
C program is given below: #include < stdio.h > int main () { int i, j; char a [2] [3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; char b [3] [2]; char *p = *b; for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { *(p + 2*j + i) = a [i] [j]; } } } What should be the contents of the array b at the end of the program?